<?php
class Invite_model extends CI_Model {
	
	public function __construct() {
		parent::__construct ();
	}
	
	public function add($from,$to,$bid){
		$data = array(
				'bid' => $bid,
				'from' => $from,
				'to'=>$to
		);
		$this->db->insert('invite', $data);
		return $this->db->insert_id();
	}
	
	public function be_invited($uid,$bid){
		$query = $this->db->get_where('invite',array('to'=>$uid,'bid'=>$bid));
		return $query->num_rows()>0;
	}
	
	public function get($iid){
		$query = $this->db->get_where('invite',array('iid'=>$iid));
		return $query->row_array();
	}
	
	public function delete($iid){
		$this->db->delete('invite',array('iid'=>$iid));
	}
}

?>